﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseSet.Data;
using BaseSet.Logic;
using BaseSet.Entity;
using BaseSet.Framework;
using BaseSet.Entity.Common;
using BaseSet.Entity.Common.Text;
using BaseSet;
using System.Data;

namespace WebSite.Ajax
{
    public partial class CheckLoginValue : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string username = Request.QueryString["username"] + "";
            string password = Request.QueryString["password"] + "";

            UsersHelper uhelper = new UsersHelper();
            Criteria c = new Criteria();
            c.Add(CriteriaType.Equals, "UserName", username);
            c.Add(CriteriaType.Equals, "Password", Encrypt.Encode(password));
            c.Add(CriteriaType.Equals, "RoleType", 1);
            List<Users> userlist = uhelper.QueryUsersBySearch(c, null);

            if (userlist != null && userlist.Count > 0)
            {
                Users user = userlist[0];
                Session["CurrentUser"] = user;
                Response.Write("OK");
                return;
            }
            else
            {
                Response.Write("用户名或密码错误");
                return;
            }
        }
    }
}